'use strict';

import { roleModel } from "../model/role";
import { ServiceBase, Exceptions } from '../kalend';
import { menuService } from "./menu";

class RoleService extends ServiceBase {
    constructor() {
        super(roleModel)
    }
    async query() {
        return super.queryAll();
    }
    async querybyId(id: any) {
        let role = await this.queryById(id);
        const menus = await menuService.getTree(role.rights);
        role.menus = menus;
        return role;
    }
    async queryalls(filter: any){
        return this.queryAll({filter: filter});
    }
}

export const roleService = new RoleService();